package com.itheima;

public class Test07 {
    public static void main(String[] args) {
        int code = 0;
        try {
            method(1);
            code = 101;
        } catch (ArithmeticException e) {
            code = 404;
        } catch (ArrayIndexOutOfBoundsException e) {
            code = 505;
        } catch (NullPointerException e) {
            code = 606;
        }
        System.out.println("程序结束");
        System.out.println("code=" + code);
    }

    public static void method(int num) throws ArithmeticException, ArrayIndexOutOfBoundsException, NullPointerException {
        if (num == 1) {
            System.out.println(3 / 0);
        }
        if (num == 2) {
            int[] arr = new int[3];
            System.out.println(arr[4]);
        }
        if (num == 3) {
            String s = null;
            System.out.println(s.length());
        }
        System.out.println("程序正常运行");
    }
}
